import {OPERATE_PRODUCT} from "@/static/enum";

export const useDealProduct = (type: string, data: any, dispatch: any) => {
  switch(type){
    case OPERATE_PRODUCT.ADD:
      dispatch({
        type: 'products/setShippingList',
        payload: {...data}
      });
      return;
    case OPERATE_PRODUCT.REMOVE:
      dispatch({
        type: 'products/removeProduct',
        payload: {...data}
      });
      return
    case OPERATE_PRODUCT.DELETE:
      dispatch({
        type: 'products/deleteProduct',
        payload: {...data}
      });
      return
    case OPERATE_PRODUCT.PUSH:
      dispatch({
        type: 'products/setShippingList',
        payload: {...data}
      });
      return;
    default:
      dispatch({
        type: 'products/clearShippingList',
        payload: {...data}
      });
  }
}
